package com.sso.controller;

import java.io.IOException;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sso.utils.AjaxHelper;
import com.sso.utils.CookieUtils;

/**
 * <p>
 * 应答是否登录
 * </p>
 */
@Controller
public class ReplyLoginController extends BaseController {

	/**
	 * 回复子系统是否登录
	 */
	@ResponseBody
	@RequestMapping("/replylogin")
	public void replylogin() throws IOException {
		StringBuffer replyData = new StringBuffer();
		replyData.append(request.getParameter("callback")).append("({\"msg\":\"");
		String token = CookieUtils.getCookieValue(request, "SSO-TOKEN");
		if (token != null) {
			replyData.append(token);
		} else {
			// 未登录
			replyData.append("-1");
		}
		replyData.append("\"})");
		AjaxHelper.outPrint(response, replyData.toString(), "UTF-8");
	}

}
